<extend name='Index/index' />

<block name="main">
                <div class="bg-light lter b-b wrapper-md">
                    <h1 class="m-n font-thin h3">聊天室管理</h1>
                </div>
                <div class="wrapper-md">
                    <div class="panel panel-default">
                        <div class="table-responsive">
                            <table class="table table-striped b-t b-light" style="table-layout: fixed;">
                                <thead>
                                    <tr>
                                        <th>消息ID</th>
                                        <th>发送人</th>
                                        <th>内容</th>
                                        <th>发送时间</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <volist name='data' id='s'>
                                    <tr>
                                        <td title="<{$s.mesId}>" style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><{$s.mesId}></td>
                                        <td title="<{$s.sender}>" style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><{$s.sender}></td>
                                        <td title="<{$s.content}>" style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;"><{$s.content}></td>
                                        <td title="<{$s.sendTime}>" style="white-space:nowrap;overflow:hidden;text-overflow: ellipsis;">
                                        <{$s.sendTime}>
                                        <td> 
                                        <button class='btn btn-danger'>删除</button>
                                        </td>
                                    </tr>
                                    </volist>
                                </tbody>
                            </table>
                            <{$page}>
                        </div>
                    </div>
                </div>

<script type="text/javascript">

            $("button:contains('删除')").click(function(){
                var mesId = $(this).parents('tr').children('td').eq(0).html();
                $(this).parents('tr').remove();
                $.ajax({
                url:"<{:U('d')}>",
                type:"POST",
                data:{'mesId':mesId},
                dataType:'json', 
                success: function(data){
                    if(data == 1){
                        alert('删除成功');
                    }else{
                        alert('删除失败');
                    }
                    }
                })
            })
    
</script>
</block>
